package org.opensmile.study.basic.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

public class ISAndOSStudy {

	public static String ReadFile1(File file){
		String xml="";
		return xml;
	}
	
	public static String ReadFile(File file) throws UnsupportedEncodingException{
		String xml="";
		try {
			if(file ==null || !file.exists()) return null;
					if(file.isDirectory()){
					String[] strs =FileStudy.getFileList(file.getPath(), ".*");
					for(String str:strs){
						String strpath=file.getPath()+"\\"+str;
						xml+=strpath+"\n\r";
						 xml+= ReadFile(new File(strpath));
							xml+="\n\r";
					}
				}else{
					FileInputStream fis =new FileInputStream(file);
					byte[] b =new byte[1];
					while(fis.read(b)>0){
						xml+=new String(b);
					}
				}
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	
		return xml;
	}
}
